package com.situ.day6;

import org.junit.Test;

import java.util.Scanner;

public class Demo {

    //NullPointerException空指针异常（引用数据类型）
    @Test
    public void test1() {
        //在同一个包下面的类不用import就可以使用
        Student student;
        //我们常用的很多类都在java.lang包下面
        String str;
        //java.util.
        Scanner scanner;
    }

    //NullPointerException空指针异常（引用数据类型）
    @Test
    public void test2() {
        Student student = null;
        System.out.println(student);
        //null.属性  null.方法
        //java.lang.NullPointerException:
        // Cannot read field "name" because "student" is null
        //System.out.println(student.name);
        student.study();
    }

    @Test
    public void test3() {
        Student student = new Student();
        //student.id = 1;
        //student.age = 150;
        student.setId(1);
        student.setName("lisi");
        student.setAge(345);

        int id = student.getId();
        String name = student.getName();
        int age = student.getAge();

        System.out.println("id: " + id);
        System.out.println("name: " + name);
        System.out.println("age: " + age);
    }

    @Test
    public void test66() {
        Student student = new Student(2, "王五", 23, "男");
        System.out.println(student.getName());
        System.out.println(student);

    }
}
